namespace Test
import Grawlix

final class A:
	
	val as int
	
	[Equality(InvertOperators: true)]
	private def Equality(rhs as Compare):
		return val == rhs.val

struct Compare:
	public val as int

a = A()
b as object = a
c = Compare()
d as object = c
x as A = null
#y as Compare = null # Compare is a value type
z as object = null

assert     a.Equals(a)
assert     a.Equals(b)
assert     a.Equals(c)
assert     a.Equals(d)
assert not a.Equals(x)
#assert not a.Equals(y) # no y
assert not a.Equals(z)
assert not a.Equals(null)
assert     a == a
assert     a == b
assert     a == c
assert     a == d
assert not a == x
#assert not a == y # no y
assert not a == z
assert not a == null
assert not a != a
assert not a != b
assert not a != c
assert not a != d
assert     a != x
#assert     a != y # no y
assert     a != z
assert     a != null

assert     b.Equals(a)
assert     b.Equals(b)
assert     b.Equals(c)
assert     b.Equals(d)
assert not b.Equals(x)
#assert not b.Equals(y) # no y
assert not b.Equals(z)
assert not b.Equals(null)
assert     b == a
assert     b == b
assert     b == c
assert     b == d
assert not b == x
#assert not b == y # no y
assert not b == z
assert not b == null
assert not b != a
assert not b != b
assert not b != c
assert not b != d
assert     b != x
#assert     b != y # no y
assert     b != z
assert     b != null

assert not c.Equals(a) # Can't change original
assert not c.Equals(b) # Can't change original
assert     c.Equals(c)
assert     c.Equals(d)
assert not c.Equals(x)
#assert not c.Equals(y) # no y
assert not c.Equals(z)
assert not c.Equals(null)
assert     c == a
assert     c == b
assert     c == c
assert     c == d
assert not c == x
#assert not c == y # no y
assert not c == z
#assert not c == null # Can't convert null to Compare
assert not c != a
assert not c != b
assert not c != c
assert not c != d
assert     c != x
#assert     c != y # no y
assert     c != z
#assert     c != null # Can't convert null to Compare

assert not d.Equals(a) # Can't change original
assert not d.Equals(b) # Can't change original
assert     d.Equals(c)
assert     d.Equals(d)
assert not d.Equals(x)
#assert not d.Equals(y) # no y
assert not d.Equals(z)
assert not d.Equals(null)
assert     d == a
assert     d == b
assert     d == c
assert     d == d
assert not d == x
#assert not d == y # no y
assert not d == z
assert not d == null
assert not d != a
assert not d != b
assert not d != c
assert not d != d
assert     d != x
#assert     d != y # no y
assert     d != z
assert     d != null

# Cannot call method on null
#assert not x.Equals(a)
#assert not x.Equals(b)
#assert not x.Equals(c)
#assert not x.Equals(d)
#assert     x.Equals(x)
#assert     x.Equals(y)
#assert     x.Equals(z)
#assert     x.Equals(null)
assert not x == a
assert not x == b
assert not x == c
assert not x == d
assert     x == x
#assert     x == y # no y
assert     x == z
assert     x == null
assert     x != a
assert     x != b
assert     x != c
assert     x != d
assert not x != x
#assert not x != y # no y
assert not x != z
assert not x != null

# No y
#assert not y.Equals(a)
#assert not y.Equals(b)
#assert not y.Equals(c)
#assert not y.Equals(d)
#assert     y.Equals(x)
#assert     y.Equals(y)
#assert     y.Equals(z)
#assert     y.Equals(null)
#assert not y == a
#assert not y == b
#assert not y == c
#assert not y == d
#assert     y == x
#assert     y == y
#assert     y == z
#assert     y == null
#assert     y != a
#assert     y != b
#assert     y != c
#assert     y != d
#assert not y != x
#assert not y != y
#assert not y != z
#assert not y != null

# Cannot call method on null
#assert not z.Equals(a)
#assert not z.Equals(b)
#assert not z.Equals(c)
#assert not z.Equals(d)
#assert     z.Equals(x)
#assert     z.Equals(y)
#assert     z.Equals(z)
#assert     z.Equals(null)
assert not z == a
assert not z == b
assert not z == c
assert not z == d
assert     z == x
#assert     z == y # no y
assert     z == z
assert     z == null
assert     z != a
assert     z != b
assert     z != c
assert     z != d
assert not z != x
#assert not z != y # no y
assert not z != z
assert not z != null

# Cannot call method on null
#assert not null.Equals(a)
#assert not null.Equals(b)
#assert not null.Equals(c)
#assert not null.Equals(d)
#assert     null.Equals(x)
#assert     null.Equals(y)
#assert     null.Equals(z)
#assert     null.Equals(null)
assert not null == a
assert not null == b
#assert not null == c # Can't convert null to Compare
assert not null == d
assert     null == x
#assert     null == y # no y
assert     null == z
assert     null == null
assert     null != a
assert     null != b
#assert     null != c # Can't convert null to Compare
assert     null != d
assert not null != x
#assert not null != y # no y
assert not null != z
assert not null != null

